Skip to content

fix(validate-env): add IRSA and EKS Pod Identity support for Bedrock …#1038

Open
alexwang2013 wants to merge 1 commit intoanthropics:mainfrom
alexwang2013:fix/bedrock-auth-irsa-eks-pod-identity
Open

fix(validate-env): add IRSA and EKS Pod Identity support for Bedrock …#1038
alexwang2013 wants to merge 1 commit intoanthropics:mainfrom
alexwang2013:fix/bedrock-auth-irsa-eks-pod-identity

Conversation

@alexwang2013
Copy link

Summary

This PR fixes a security gap in validate-env.ts where Bedrock authentication only accepted static long-lived IAM user credentials, making it incompatible with recommended AWS security practices for containerized workloads (EKS, GitHub Actions OIDC, etc.).

Problem

The existing validation required either:

  • AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY (long-lived IAM user keys), or
  • AWS_BEARER_TOKEN_BEDROCK (static bearer token)

This forced users running Claude Code in EKS or GitHub Actions to create IAM users with long-lived credentials — which violates AWS best practices and introduces unnecessary security risk (credential leakage, no automatic rotation, no expiry).

The AWS SDK already supports temporary credentials via its credential provider chain, but the hard validation failure prevented it from ever being reached.

Changes

  • Added support for IRSA (IAM Roles for Service Accounts) via AWS_WEB_IDENTITY_TOKEN_FILE + AWS_ROLE_ARN
  • Added support for EKS Pod Identity via AWS_CONTAINER_CREDENTIALS_FULL_URI + AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE
  • Added validation that detects and errors on partial configuration of either mechanism (e.g. only one of a required pair set)
  • Improved the fallback error message to clearly list all 4 supported auth methods

Security Impact

Users can now authenticate using short-lived, automatically rotated credentials via IAM Roles — no IAM users or long-lived keys required. This aligns with AWS security best practices for containerized workloads.

Supported Auth Methods (after this PR)

Method Environment Variables
Static IAM credentials AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY
Bedrock bearer token AWS_BEARER_TOKEN_BEDROCK
IRSA AWS_WEB_IDENTITY_TOKEN_FILE + AWS_ROLE_ARN
EKS Pod Identity AWS_CONTAINER_CREDENTIALS_FULL_URI + AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE

…auth

Previously, the Bedrock credential validation only accepted static IAM
user keys (AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY) or a bearer token
(AWS_BEARER_TOKEN_BEDROCK), which forced users to create long-lived IAM
user credentials — a security anti-pattern in containerized environments.

This commit adds support for two additional AWS credential mechanisms
that are natively supported by the AWS SDK credential provider chain:

- IRSA (IAM Roles for Service Accounts): requires both
  AWS_WEB_IDENTITY_TOKEN_FILE and AWS_ROLE_ARN to be set together
- EKS Pod Identity: requires both AWS_CONTAINER_CREDENTIALS_FULL_URI
  and AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE to be set together

Partial configuration of either mechanism (only one of a required pair)
now produces a specific, actionable error message rather than falling
through to a generic 'no credentials found' failure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant